package com.zlzxm.shoesmarket.view.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.ADTransferGoods;
import com.zlzxm.shoesmarket.viewmodel.VMRequestGoods;

import java.util.zip.ZipEntry;

/**
 * CREATE BY zlzxm ON 4/21/21
 */
public class FMRequestGoods extends BaseFragment{


    public static FMRequestGoods newInstance() {

        Bundle args = new Bundle();

        FMRequestGoods fragment = new FMRequestGoods();
        fragment.setArguments(args);
        return fragment;
    }

    private FMRequestGoods() {
    }


    private RecyclerView recyclerView;

    private final ADTransferGoods adTransferGoods = new ADTransferGoods(null);

    private VMRequestGoods vmRequestGoods;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fm_request_goods,container,false);
    }

    @Override
    protected void initView(@NonNull View view, @NonNull Bundle savedInstanceState) {
        super.initView(view, savedInstanceState);

        recyclerView = ZViewHelp.findById(view,R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));


    }

    @Override
    protected void initViewModel() {
        super.initViewModel();

        vmRequestGoods = new ViewModelProvider(this).get(VMRequestGoods.class);

        vmRequestGoods.getLiveTransferGood().observe(this,adTransferGoods::setList);

    }

    @Override
    protected void initData() {
        super.initData();
        recyclerView.setAdapter(adTransferGoods);

        vmRequestGoods.requestTransferGood();
    }
}
